/*
THIS FILE IS PART OF THE >>ADRENALIN-3D-GRAFIC-ENGINE<<
for latest info visit http://www.creative-games.de

Copyright (c) 2008-2009 by Marco Schneider

This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License (LGPL) as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
License for more details.

*/

#ifndef __ADL_TIMER_H__
#define __ADL_TIMER_H__

#include "Defines.h"
#include "Singleton.h"
#include "Log.h"
#pragma comment (lib, "WinMM.lib")

namespace Adrenalin
{
	class ADRENALIN_API Timer  : public Singleton<Timer>
	{
		friend Singleton<Timer>;

	public:
	    
		EResult Start(void);
		EResult Stop(void);
		EResult Update(void);

		bool    IsTimerRunning(void)	{ return _timer; }
	    
		float   FPS(void)			{ return _fps; }
		float	Min(void)			{ return _min; }
		float	Max(void)			{ return _max; }
		float	Average(void)		{ return _average; }
		float   RunningTime(void)	{ return _runningTime; }
		float   ElapsedTime(void)	{ return _timeElapsed; } //_bTimer ? 0.0f : _fTimeElapsed; }
		long	TimeUp(void)		{ return GetTickCount(); }
	private:
		Timer(void);
		virtual ~Timer(void);

		__int64 _ticksPerSecond;
		__int64 _currentTime;
		__int64 _lastTime;
		__int64 _lastFPSUpdate;
		__int64 _fpsUpdateInterval;
	    
		long    _numFrames;
	    
		float   _runningTime;
		float   _timeElapsed;
		float   _fps;
		float	_min;
		float	_max;
		float	_average;
	    
		bool    _timer;
	};
};
#endif